<head>
<head profile="http://gmpg.org/xfn/11">
    <meta charset="UTF-8">

    <title>iPad Air Cellular 64GB | Thegioididong.com</title>
    <meta name="keywords" content="iPad Air Cellular 64GB,iPad Air Cellular,iPad Air 64GB,iPad Air,iPad, Air,Cellular 64GB">
    <meta name="description" content="iPad Air ra mắt có những nâng cấp lớn về thiết kế, cấu hình, hệ điều hành so với các thế hệ iPad trước của Apple. Mang lại những trãi nghiệm đột phá đầy thú vị">
    <meta property="og:url" itemprop="url" content="http://www.thegioididong.com/may-tinh-bang/ipad-air-cellular-64gb">
    <meta property="og:title" content="iPad Air Cellular 64GB | Thegioididong.com">
    <meta property="og:description" itemprop="description" content="iPad Air ra mắt có những nâng cấp lớn về thiết kế, cấu hình, hệ điều hành so với các thế hệ iPad trước của Apple. Mang lại những trãi nghiệm đột phá đầy thú vị">
    <meta property="og:image" content="http://cdn.tgdd.vn/Products/Images/522/60942/Apple-iPad-Air-300-1-nowatermark-300x300.jpg">
    <meta property="article:published_time" content="12/10/2013 4:18:24 PM">
    <meta property="article:modified_time" content="12/23/2013 6:04:00 PM">
    <meta property="article:section" content="Apple (iPad)">
    <meta property="article:tag" content="iPad Air Cellular 64GB/Wifi/3G">

    <meta name="RATING" content="GENERAL">
    <meta name="bitly-verification" content="811bf9d76554">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta content="INDEX,FOLLOW" name="robots">
    <meta name="viewport" content="width=device-width">
    <meta name="copyright" content="Công ty Cổ phần Thế Giới Di Động">
    <meta name="author" content="Công ty Cổ phần Thế Giới Di Động">
    <meta http-equiv="audience" content="General">
    <meta name="resource-type" content="Document">
    <meta name="distribution" content="Global">
    <meta name="revisit-after" content="1 days">
    <meta name="GENERATOR" content="Công ty Cổ phần Thế Giới Di Động">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon">
    <meta name="viewport" content="width=device-width">
    <link rel="publisher" href="https://plus.google.com/u/0/104496008508234446208">
    <meta property="og:site_name" content="Thegioididong.com">
    <meta property="og:type" content="website">
    <meta property="og:locale" content="vi_VN">
    <meta property="fb:app_id" content="505429329544659">
    <!--[if IE]>
                <link rel="stylesheet" href="/Content/core/ie.css">
        <![endif]-->

    <link rel="stylesheet" href="http://s.tgdd.vn/v2013/Content/detailv2.min.css?v=201312231135">
    <!--[if lt IE 9]>
                <script src="/Scripts/html5.js"></script>
                <script src="/Scripts/css3-mediaqueries.js"></script>
    <![endif]-->
    <script type="text/javascript" async="" src="//s3.amazonaws.com/ki.js/51153/aQw.js"></script><script type="text/javascript" async="" src="http://stats.g.doubleclick.net/dc.js"></script><script src="http://s.tgdd.vn/v2013/Scripts/jquery-1.8.3.min.js" style=""></script>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script><script src="http://maps.gstatic.com/intl/vi_vn/mapfiles/api-3/15/5/main.js" type="text/javascript"></script>
    <script type="text/javascript" async="" src="http://www.thegioididong.com/commentse/Scripts/comment.js?v=201312231135"></script><link rel="stylesheet" type="text/css" media="all" href="http://www.thegioididong.com/commentse/Content/comment_min.min.css"><link rel="stylesheet" type="text/css" media="all" href="http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic|Open+Sans+Condensed:300,700"><script type="text/javascript" charset="UTF-8" src="http://maps.gstatic.com/cat_js/intl/vi_vn/mapfiles/api-3/15/5/%7Bcommon,util,stats%7D.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
</head>
<body>
    <?php require_once 'model/db2.php'; ?>
    <h1>NguyenBaoThien</h1>

    <form method="POST">
        Min Like : <input type="text" name="Min" id="min_fans" value="5"><br>
        Max Like:  <input type="text" name="Max" value="10"><br>
        Keyword : <input type="text" name="Keyword" value="cafe"><br>
        Company: <select name="id_company">
            <?php
            $companies = getPage("SELECT * FROM companies");
            ?>
            <option value="0"><?php echo "<-----------Company----------->" ?></option>
            <?php foreach ($companies as $company): ?>
                <option value="<?php echo $company['id'] ?>"><?php echo $company['name'] ?></option>
            <?php endforeach; ?>
        </select> </br>
        Apps: <select name="id_app">
            <?php
            $apps = getApps("SELECT * FROM apps");
            ?>
            <option value="0"><?php echo "<------------------------Apps------------------------->" ?></option>
            <?php foreach ($apps as $app): ?>
                <option value="<?php echo $app['id'] ?>"><?php echo $app['name'] ?></option>
            <?php endforeach; ?>
        </select></br>

        <input type="submit" name="submit" value="Search">
        <div id="check">Check</div>
    </form>

    <?php
    $query = "SELECT * FROM pages";
    $pages = getPage($query);
    ?>
    <?php if (isset($_POST['submit'])): ?>
        <?php
        $min_fans = $_POST['Min'];
        $max_fans = $_POST['Max'];
        $keyword = $_POST['Keyword'];
        $company = $_POST["id_company"];
        $app = $_POST["id_app"];

        if (!empty($min_fans))
            $min_fans = "(likes >= $min_fans) AND";
        else
            $min_fans = "";
        if (!empty($max_fans))
            $max_fans = "(likes <= $max_fans) AND";
        else
            $max_fans = "";
        if (!empty($company))
            $company = "(companies.id= $company) AND";
        else
            $company = "";
        if (!empty($app))
            $app = "(apps.id= $app) AND";
        else
            $app = "";


        $query = "SELECT * FROM pages
                    INNER JOIN apps_pages ON pages.id=apps_pages.id_page
                    INNER JOIN apps ON apps.id=apps_pages.id_app
                    INNER JOIN companies ON companies.id=apps.id_company
                  WHERE $min_fans
                        $max_fans
                        $company
                        $app
                        (description LIKE '% $keyword %')
                        LIMIT 0, 10 
                ";
        var_dump($query);
        $pages = getPage($query);
        ?>
        <?php if (!empty($pages)): ?>
            <script type="text/javascript">
                alert("Hello World");
            </script>

            <table border ="1">
                <tr>
                    <td class="pid">STT </td>
                    <td class="picture">picture </td>
                    <td class="id">ID</td>
                    <td class="name">Name</td>
                    <td class="likes">Likes</td>
                    <td class="talking">Talking</td>
                    <td class="category">Category</td>
                    <td class="link">Link </td>
                    <td class="website">Website</td>
                    <td class="country">Country </td>
                </tr>
                <?php foreach ($pages as $page): ?>
                    <tr>
                        <td><?php echo $page["pid"] ?></td>
                        <td><img src = '<?php echo $page["picture"] ?>'></td>
                        <td><?php echo $page["id"] ?></td>
                        <td><?php echo $page["name"] ?></td>
                        <td><?php echo $page["likes"] ?></td>
                        <td><?php echo $page["talking_about_count"] ?></td>
                        <td><?php echo $page["category"] ?></td>
                        <td><?php echo $page["link"] ?></td>
                        <td><?php echo $page["website"] ?></td>
                        <td><?php echo $page["country"] ?></td>
                    </tr>
                <?php endforeach; ?>
            </table>
            
        <?php endif; ?>
            
    <?php endif; ?>
           
            <script>
            $(document).ready(function (){
             
                $('#check').click(function (){ 
                var min=$("#min_fans").val();
                if(checkNumber(min))
                    alert("is num");
                else
                    alert("Not num");
                });
           
            function checkNumber(val){
                if($.isNumeric(val))
                    return true;
                else
                    return false;
            }
             });
            </script>
          
</body>
